package com.aos.iot.protocol.hll.log.builder;

import com.aos.iot.socket.common.message.Message;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Component
public class ILogBuilderFactor {

    private final Map<Class<? extends Message>, ILogBuilder> logBuilderMap;

    public ILogBuilderFactor(List<ILogBuilder> logBuilders) {
        this.logBuilderMap = logBuilders.stream().collect(Collectors.toMap(ILogBuilder::messageClass, ILogBuilder::logBuilder));
    }

    public ILogBuilder getLogBuilder(Class<? extends Message> mClass) {
        return logBuilderMap.get(mClass);
    }

}
